package com.glsc.ngateway.common.base.repo.mysql.cmdb;

import com.glsc.ngateway.common.base.domain.mysql.cmdb.CmdbDeviceType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface CmdbDeviceTypeRepository extends JpaRepository<CmdbDeviceType, Integer>, JpaSpecificationExecutor<CmdbDeviceType> {
//    Page<CmdbDeviceType> searchByParam(Pageable pageable, CmdbDeviceType paramSearchDto);

    @Transactional
    @Modifying
    @Query(value = "update t_cmdb_device_type set is_delete = :deleted where device_type_id in :codes ", nativeQuery = true)
    void updateIsDeleteByCodes(Integer deleted, List<String> codes);

    List<CmdbDeviceType> findByIsDelete(Integer isDelete);
}

